"use strict";
cc._RF.push(module, '6b843mz0ohLrYk5K1sit0Kn', 'WXSDK');
// scripts/WXSDK.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _n29,
    i = void 0 && (void 0).__extends || (_n29 = function n(t, e) {
  return (_n29 = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _n29(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
});

Object.defineProperty(o, "__esModule", {
  value: !0
});

var s = t("BaseSdk"),
    r = t("SDKEvent"),
    c = t("Common"),
    a = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e._recorderShareFunc = null, e._musicPauseFunc = null, e._musicPauseThis = null, e._musicResumeFunc = null, e._musicResumeThis = null, e._clipboardData = "", e._playScreenTime = 0, e._screenSpaceTime = 0, e._interstitiaId = "", e._moreGameBtn = null, e._recorder = null, e.lastAdTime = 0, e._recorderStatus = 0, e._recorderEndTime = 0, e._recorderTime = 0, e._videoId = "adunit-6384cbfeeb712cfd", e._bannerId = "adunit-379f013d20d019c6", e._screenId = "adunit-fca3d4ef37cd217f", e._screenId2 = "adunit-25c887f1c745b184", e._portalId = "PBgAAwpm9LNY17Dc", e._shareId = "cPtOicL/Rcq/M4860CbA0g==", e._shareTitle = "文字乐翻天", e._shareDesc = "一起来拼字吧", e._videoLoaded = !1, e._videoOptions = null, e._videoAd = null, e._bannerLoaded = !1, e.gridAd = null, e.banner = null, e.singleCustomAd = null, e.rightSingleCustomAd = null, e.rightButtomCustomAd = null, e.leftCustomAd = null, e.rightCustomAd = null, e.lastshockTime = 0, e.shareBtn = null, e.screenShow = !0, e.launchInfo = "", e.serverScene = null, e.sdkVersion = 0, e;
  }

  return i(e, t), e.prototype.init = function () {
    var t = this;
    this.lastAdTime = new Date().getTime(), wx.showShareMenu(), wx.onShareAppMessage(function () {
      return {
        title: t._shareTitle,
        query: "",
        success: function success() {
          console.log("分享成功");
        },
        fail: function fail(t) {
          console.log("分享失败", t);
        }
      };
    });
    var e = wx.getSystemInfoSync().SDKVersion,
        o = new RegExp("\\.", "g");
    e = e.replace(o, ""), this.sdkVersion = parseInt(e);
    var n = wx.getUpdateManager();
    n.onCheckForUpdate(function (t) {
      console.log(t.hasUpdate);
    }), n.onUpdateReady(function () {
      wx.showModal({
        title: "更新提示",
        content: "新版本已经准备好，是否立即使用？",
        showCancel: !1,
        success: function success() {
          n.applyUpdate();
        }
      });
    }), n.onUpdateFailed(function () {}), this._preloadVideo(), this.launchInfo = wx.getLaunchOptionsSync();
  }, e.prototype._preloadVideo = function () {
    var t = this;
    this._videoAd = wx.createRewardedVideoAd({
      adUnitId: t._videoId
    }), this._videoAd.onLoad(function () {
      t._videoLoaded = !0;
    }), this._videoAd.load().then(function () {
      t._videoLoaded = !0;
    }), this._videoAd.onClose(function (e) {
      t._videoLoaded = !1, t.lastAdTime = new Date().getTime(), e.isEnded ? t._videoOptions && t._videoOptions.success && t._videoOptions.success() : wx.showModal({
        title: "奖励提醒",
        content: "中途关闭视频无法获得奖励，是否继续获得奖励？",
        success: function success(e) {
          e.confirm ? t.showRewardVideo(t._videoOptions) : e.cancel;
        },
        fail: function fail() {
          console.log("showModal调用失败");
        }
      }), t._videoAd.load().then(function () {
        console.log("广告关闭后重新加载成功"), t._videoLoaded = !0;
      });
    }), this._videoAd.onError(function () {
      t._videoLoaded = !1, console.log("加载失败，尝试重试"), setTimeout(function () {
        t._videoAd.load().then(function () {
          t._videoLoaded = !0;
        });
      }, 1e4);
    });
  }, e.prototype.showCustomAd = function () {
    var t = wx.getSystemInfoSync(),
        e = t.windowWidth,
        o = t.windowHeight;
    this.singleCustomAd || (this.singleCustomAd = wx.createCustomAd({
      adUnitId: "adunit-641db76d7906eebe",
      style: {
        left: 20,
        top: o / 2 - 50
      }
    })), this.singleCustomAd.show(), this.rightButtomCustomAd || (this.rightButtomCustomAd = wx.createCustomAd({
      adUnitId: "adunit-ff6871d3fc8ebef6",
      style: {
        left: e - 290,
        top: o - 90
      }
    })), this.rightButtomCustomAd.show();
  }, e.prototype.hideCustomAd = function () {
    this.singleCustomAd && this.singleCustomAd.hide(), this.rightButtomCustomAd && this.rightButtomCustomAd.hide();
  }, e.prototype.showCustomAdBig = function () {
    if (this.sdkVersion >= 2111) {
      var t = wx.getSystemInfoSync(),
          e = t.windowWidth,
          o = t.windowHeight;
      this.leftCustomAd || (this.leftCustomAd = wx.createCustomAd({
        adUnitId: "adunit-28fc00f8883c84ac",
        style: {
          left: 20,
          top: o / 2 - 150
        }
      })), this.leftCustomAd.show(), this.rightCustomAd || (this.rightCustomAd = wx.createCustomAd({
        adUnitId: "adunit-556cd26ad6980153",
        style: {
          left: e - 80,
          top: o / 2 - 150
        }
      })), this.rightCustomAd.show();
    }
  }, e.prototype.hideCustomAdBig = function () {
    this.leftCustomAd && this.leftCustomAd.hide(), this.rightCustomAd && this.rightCustomAd.hide();
  }, e.prototype.showGridAd = function () {
    if (this.sdkVersion >= 2111) {
      if (!this.gridAd) {
        var t = wx.getSystemInfoSync(),
            e = t.windowWidth;
        t.windowHeight, this.gridAd = wx.createCustomAd({
          adUnitId: "adunit-9835ce04602abfc2",
          style: {
            left: e / 2 - 175,
            width: 350,
            top: 10
          }
        });
      }

      this.gridAd.show();
    }
  }, e.prototype.hideGridAd = function () {
    this.gridAd && this.gridAd.hide();
  }, e.prototype.showGridScorllAd = function () {
    if (this.sdkVersion >= 2111) {
      var t = wx.getSystemInfoSync(),
          e = t.windowWidth,
          o = t.windowHeight;
      this.rightSingleCustomAd || (this.rightSingleCustomAd = wx.createCustomAd({
        adUnitId: "adunit-50440592813d515a",
        style: {
          left: e - 80,
          top: o / 2 - 50
        }
      })), this.rightSingleCustomAd.show();
    }
  }, e.prototype.hideGridScorllAd = function () {
    this.rightSingleCustomAd && this.rightSingleCustomAd.hide();
  }, e.prototype.loadBanner = function () {
    var t = this;
    this.banner && (this.banner.destroy(), this.banner = null);
    var e = wx.getSystemInfoSync(),
        o = e.windowWidth,
        n = e.windowHeight;
    this.banner = wx.createBannerAd({
      adUnitId: t._bannerId,
      style: {
        width: 200,
        height: 100,
        left: (o - 200) / 2,
        top: n - 112.5
      }
    }), this.banner.onLoad(function () {
      t._bannerLoaded = !0, t.banner.show(), setTimeout(function () {
        t.loadBanner();
      }, 6e4);
    }), this.banner.onError(function () {
      t._bannerLoaded = !1;
    }), this.banner.onResize(function (e) {
      console.log(e.width, o, e.height, n), t.banner.style.top = n - e.height, t.banner.style.left = (o - e.width) / 2;
    });
  }, e.prototype.showBanner = function () {
    try {
      Math.random() < 0.5 ? this.banner ? this.banner.show() : this.gridAd && this.gridAd.show() : this.gridAd ? this.gridAd.show() : this.banner && this.banner.show();
    } catch (t) {}
  }, e.prototype.hideBanner = function () {
    try {
      this.banner && this.banner.hide(), this.gridAd && this.gridAd.hide();
    } catch (t) {}
  }, e.prototype.setKeepScreenOn = function (t) {
    wx.setKeepScreenOn(t);
  }, e.prototype.getUserInfo = function (t) {
    wx.login({
      success: function success(e) {
        console.log("登录成功", e);
        var o = e.code;
        wx.authorize({
          scope: "scope.userInfo",
          success: function success() {
            console.log("授权获取用户信息成功"), wx.getUserInfo({
              success: function success(e) {
                console.log("获取用户信息成功", e), t.success(e.userInfo, o);
              },
              fail: function fail(e) {
                console.log("获取信息失败", e), t.fail(o);
              }
            });
          },
          fail: function fail(e) {
            console.log("授权获取用户信息失败: " + JSON.stringify(e)), t.fail(o);
          },
          complete: function complete() {
            console.log("授权获取用户信息完成");
          }
        });
      },
      fail: function fail() {
        console.log("login调用失败"), t.fail();
      }
    });
  }, e.prototype.login = function (t) {
    var e = this;
    console.log("头条登录"), wx.login({
      force: t.force,
      success: function success(o) {
        console.log("login调用成功", o);
        var n = o.code,
            i = o.anonymousCode;
        if (o.isLogin) wx.getUserInfo({
          success: function success(o) {
            var i = JSON.stringify(o.userInfo),
                s = {
              code: n,
              json: i,
              visitor: !1
            };
            e.sendHttpRequest("Common.ttLoginUrl", s, function (e) {
              var o = e.data;
              0 == o.user.status ? (console.log("登录完成，准备回调"), t.success(o)) : (console.log("用户状态异常"), t.fail("你因违规操作,帐号已被系统冻结"));
            }, function (e) {
              console.log("request调用失败", e), t.fail("网络繁忙,请稍后再试");
            });
          },
          fail: function fail(o) {
            console.log("getUserInfo 调用失败", o);
            var n = {
              code: i,
              json: "{}",
              visitor: !0
            };
            e.sendHttpRequest("Common.ttLoginUrl", n, function (e) {
              var o = e.data;
              0 == o.user.status ? (console.log("登录完成，准备回调"), t.success(o)) : (console.log("用户状态异常"), t.fail("你因违规操作,帐号已被系统冻结"));
            }, function (e) {
              console.log("request调用失败", e), t.fail("网络繁忙,请稍后再试");
            });
          }
        });else {
          var s = {
            code: i,
            json: "{}",
            visitor: !0
          };
          e.sendHttpRequest("Common.ttLoginUrl", s, function (e) {
            var o = e.data;
            0 == o.user.status ? (console.log("登录完成，准备回调"), t.success(o)) : (console.log("用户状态异常"), t.fail("你因违规操作,帐号已被系统冻结"));
          }, function (e) {
            console.log("request调用失败", e), t.fail("网络繁忙,请稍后再试");
          });
        }
      },
      fail: function fail(e) {
        console.log("login调用失败", e), t.fail("登录失败,请稍后再试");
      }
    });
  }, e.prototype.createMoreGamesButton = function (t) {
    this._moreGameBtn || (console.log("创建更多游戏"), this._moreGameBtn = wx.createMoreGamesButton({
      type: "image",
      image: "images/moregame.png",
      style: {
        left: t.left,
        top: t.top,
        width: t.width,
        height: t.height,
        lineHeight: 49,
        backgroundColor: "#00000000",
        textColor: "#ffffff",
        textAlign: "center",
        fontSize: 16,
        borderRadius: 4,
        borderWidth: 1,
        borderColor: "#00000000"
      },
      appLaunchOptions: [],
      onNavigateToMiniGame: function onNavigateToMiniGame(t) {
        console.log("跳转其他小游戏", t);
      }
    }), this._moreGameBtn.onTap(function () {
      console.log("点击更多游戏");
    }));
  }, e.prototype.getOpenDataContext = function () {
    return wx.getOpenDataContext();
  }, e.prototype.postMessage = function (t) {
    console.log("推送开放数据", t), wx.getOpenDataContext().postMessage(t);
  }, e.prototype.startRecorder = function () {
    this._recorder && !this._isRecorder && (console.log("准备开始录屏"), this._recorderTime = new Date().getTime(), this._isRecorder = !0, this._recorder.start({
      duration: 60
    }), cc.systemEvent.emit(r["default"].CHANGE_RECORDER_STATE));
  }, e.prototype.stopRecorder = function (t) {
    this._recorder && this._isRecorder && (console.log("准备停止录屏"), this._recorderEndTime = new Date().getTime(), this._recorderShareFunc = t, this._recorder.stop(), this._isRecorder = !1, cc.systemEvent.emit(r["default"].CHANGE_RECORDER_STATE));
  }, e.prototype.getRecorderTime = function () {
    return this._recorderEndTime - this._recorderTime;
  }, e.prototype.getIsScreenRecordVideo = function () {
    return !1;
  }, e.prototype.getRecorderState = function () {
    return this._isRecorder;
  }, e.prototype.showShareBtn = function () {}, e.prototype.hideShareBtn = function () {}, e.prototype.shareRecorder = function (t) {
    var e = t.query;
    wx.shareAppMessage({
      channel: "video",
      title: this._shareTitle,
      desc: this._shareDesc,
      templateId: this._shareId,
      query: e,
      success: function success(e) {
        console.log("分享视频成功"), t.success && t.success(e.videoId);
      },
      fail: function fail(e) {
        console.log("分享视频失败", e), t.fail && t.fail(e);
      },
      complete: function complete() {}
    });
  }, e.prototype.showRewardVideo = function (t) {
    var e = this;
    if (!e._videoAd) return t && t.success && t.success();
    e._videoOptions = t, e._videoAd.show().then(function () {})["catch"](function () {
      e._videoAd.load().then(function () {
        return e._videoAd.show();
      });
    });
  }, e.prototype.setClipboardData = function (t) {
    wx.setClipboardData({
      data: t.data,
      success: function success() {
        t.success && t.success(), console.log("调用剪切板成功", t.data);
      },
      fail: function fail() {
        t.fail && t.fail(), console.log("调用剪切板失败", t.data);
      }
    });
  }, e.prototype.getVideoState = function () {
    return this._videoLoaded;
  }, e.prototype.playScreen = function (t) {
    void 0 === t && (t = 1);
    var e = this;

    if (new Date().getTime() - this.lastAdTime > 3e4 && this.screenShow) {
      var o = wx.createInterstitialAd({
        adUnitId: 1 == t ? e._screenId : e._screenId2
      });
      o.onClose(function () {
        e.lastAdTime = new Date().getTime();
      }), o.onLoad(function () {
        console.log("微信插屏加载成功");
      }), o.onError(function (t) {
        console.log("微信插屏加载失败", t);
      }), o.show()["catch"](function (t) {
        console.log("显示插屏失败", t);
      });
    }
  }, e.prototype.sendEvent = function (t) {
    t && t.key && (console.log("上报事件:", t.key), t.value ? wx.reportAnalytics(t.key, t.value) : wx.reportAnalytics(t.key, {}));
  }, e.prototype.vibrateShort = function () {
    var t = new Date().getTime();
    t - this.lastshockTime > 100 && (this.lastshockTime = t, wx.vibrateShort({
      success: function success() {},
      fail: function fail() {
        console.log("vibrateShort调用失败");
      }
    }));
  }, e.prototype.vibrateLong = function () {
    wx.vibrateLong({
      success: function success() {},
      fail: function fail() {
        console.log("vibrateLong调用失败");
      }
    });
  }, e.prototype.showToast = function (t) {
    wx.showToast({
      title: t,
      icon: "none",
      duration: 2e3,
      success: function success() {},
      fail: function fail() {}
    });
  }, e.prototype.share = function (t) {
    wx.shareAppMessage(t);
  }, e.prototype.setLocalStorage = function (t, e) {
    cc.sys.localStorage.setItem(t, e);
  }, e.prototype.getLocalStorage = function (t) {
    return cc.sys.localStorage.getItem(t);
  }, e.prototype.sendHttpRequest = function (t, e, o, n) {
    wx.request({
      url: t,
      data: e,
      success: function success(t) {
        if (t.data.ok) {
          if (o) {
            var e = t.data;
            o(e);
          }
        } else n && n(t.data.msg);
      },
      fail: function fail(t) {
        console.log("request调用失败", t), n && n("网络繁忙,请稍后再试");
      }
    });
  }, e.prototype.contentSafe = function (t) {
    var e = {
      text: t.content
    };
    this.sendHttpRequest(c["default"].contentSafeTT, e, function (e) {
      e.valid ? t.callBack(!0) : t.callBack(!1);
    }, function () {
      t.callBack(!1);
    });
  }, e.prototype.onShow = function (t) {
    var e = this;
    wx.onShow(function (o) {
      var n = o.scene;
      e.serverScene[n] && (e.screenShow = !1), t(o);
    });
  }, e.prototype.getLaunchOptionsSync = function () {
    return this.launchInfo;
  }, e;
}(s["default"]);

o["default"] = a;

cc._RF.pop();